package com.zz.controller;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.zz.entity.Memberships;
import com.zz.entity.Students;
import com.zz.entity.StudentsSearch;
import com.zz.service.StudentsService;

@RestController
public class StudentsContrlloer {

	@Autowired
	StudentsService studentsService;

	/**
	 * 查看所有的同学
	 * 
	 * @return
	 */
	@RequestMapping("/X-admin/find")
	public Object find(StudentsSearch s, Integer page, Integer limit) {
		//System.out.println(s+"22222");
		// System.out.println(studentsService.find(s, page, limit).getContent());
		int count=studentsService.count();
		Map<String, Object>map=new HashMap<String, Object>();
		map.put("code", 0);
		map.put("msg", "");
		map.put("data", studentsService.find(s, page, limit).getContent());
		map.put("count", count);
		return map;
	}
	//添加+修改
	@RequestMapping("/X-admin/save")
	public Integer save(Students s, Memberships m) {
		    return studentsService.save(s, m);
		
	}
	//删除
	@RequestMapping("/X-admin/delete")
	public Integer delete(Integer id) {
	    
		    return studentsService.delete(id);
		
	}
	//导入表格
	 @RequestMapping("/X-admin/EStu")
	    public String EStu(MultipartFile file) throws Exception {
		 System.out.println("这是学生导入的控制层");
		 studentsService.getExcelStudents(file);
	 
	        return "上传成功";
	    }
}
